package com.tancire.net.service.impl;

import java.util.List;
import javax.annotation.Resource;

import com.tancire.common.utils.DateUtils;
import com.tancire.common.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import com.tancire.net.mapper.CrmCompanyTaskMapper;
import com.tancire.net.domain.CrmCompanyTask;
import com.tancire.net.service.ICrmCompanyTaskService;

/**
 * 客户推广Service业务层处理
 *
 * @author chenchao
 * @date 2023-12-25
 */
@Service
public class CrmCompanyTaskServiceImpl implements ICrmCompanyTaskService {
    @Resource
    private CrmCompanyTaskMapper crmCompanyTaskMapper;

    /**
     * 查询客户推广
     *
     * @param id 客户推广主键
     * @return 客户推广
     */
    @Override
    public CrmCompanyTask selectCrmCompanyTaskById(Long id) {
        return crmCompanyTaskMapper.selectCrmCompanyTaskById(id);
    }

    /**
     * 查询客户推广列表
     *
     * @param crmCompanyTask 客户推广
     * @return 客户推广
     */
    @Override
    public List<CrmCompanyTask> selectCrmCompanyTaskList(CrmCompanyTask crmCompanyTask) {
        return crmCompanyTaskMapper.selectCrmCompanyTaskList(crmCompanyTask);
    }

    /**
     * 新增客户推广
     *
     * @param crmCompanyTask 客户推广
     * @return 结果
     */
    @Override
    public int insertCrmCompanyTask(CrmCompanyTask crmCompanyTask) {
        crmCompanyTask.setCreateTime(DateUtils.getNowDate());
        return crmCompanyTaskMapper.insertCrmCompanyTask(crmCompanyTask);
    }

    /**
     * 修改客户推广
     *
     * @param crmCompanyTask 客户推广
     * @return 结果
     */
    @Override
    public int updateCrmCompanyTask(CrmCompanyTask crmCompanyTask) {
        crmCompanyTask.setUpdateTime(DateUtils.getNowDate());
        return crmCompanyTaskMapper.updateCrmCompanyTask(crmCompanyTask);
    }

    /**
     * 批量删除客户推广
     *
     * @param ids 需要删除的客户推广主键
     * @return 结果
     */
    @Override
    public int deleteCrmCompanyTaskByIds(Long[] ids) {
        return crmCompanyTaskMapper.deleteCrmCompanyTaskByIds(ids);
    }

    /**
     * 删除客户推广信息
     *
     * @param id 客户推广主键
     * @return 结果
     */
    @Override
    public int deleteCrmCompanyTaskById(Long id) {
        return crmCompanyTaskMapper.deleteCrmCompanyTaskById(id);
    }

    /**
     * 删除当前用户所属的任务
     *
     * @param id
     * @return
     */
    @Override
    public int deleteCompanyTaskById(Long id) {
        return crmCompanyTaskMapper.deleteCompanyTaskById(id, SecurityUtils.getUserId());
    }
}
